package cn.lg.soar.cloud.core.feign.fallback;

import cn.lg.soar.cloud.core.feign.LogConfigApiFeign;
import cn.lg.soar.mvc.log.LogConfigDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * 简单日志接口
 * @author luguoxiang
 * @date 2021-08-11
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@ConditionalOnMissingClass("cn.lg.soar.system.biz.modules.monitor.client.LogConfigApiClient")
public class LogConfigApiFallbackFactory implements FallbackFactory<LogConfigApiFeign> {

    protected static final Logger LOGGER = LoggerFactory.getLogger(LogConfigApiFallbackFactory.class);
    @Override
    public LogConfigApiFeign create(Throwable cause) {
        return new LogConfigApiFeign() {

            @Override
            public LogConfigDTO getLogConfig(String code) {
                LOGGER.error("getLogConfig：{}", code, cause);
                return null;
            }

        };
    }
}
